<%-- 
    Document   : update1
    Created on : 2014/8/19, 下午 03:09:54
    Author     : Yu
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    String id = request.getParameter("id");
    Class.forName("com.mysql.jdbc.Driver");
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/javadb", "root", "007341");
    Statement st = con.createStatement();
    String sql = "Select id,username,tel,birthday from person where id=" + id;
    System.out.println(sql);
%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>update1</title>
    </head>
    <body>
        <h1>-----update1-----</h1>

	<%
	    ResultSet rs = st.executeQuery(sql);
	    if (rs.next()) {

		String username = rs.getString("username");
		String tel = rs.getString("tel");
		String birthday = rs.getString("birthday");
	%>
	<form action="update2.jsp" >
	    使用者username:<input type="text" name="username" value="<%= username %>"><br>
	    電話tel:<input type="text" name="tel"value="<%= tel %>"><br>
	    生日birthday:<input type="text" name="birthday"value="<%= birthday %>"><br>
	    <input type="hidden" name="id" value="<%= id %>">
	    <input type="submit" >

                            

	    
	   <%
	    }else{
	    out.println("查無資料!");
	    }
	    rs.close();
	    st.close();
	    con.close();


	    %>
	    </body>
	    </html>
